import React from 'react';
import { connect } from 'dva';
import RiskUpdate from './update';
import UpdateResult from './result';
import { StateType } from '@/common-typings';
import { mapStateToProps } from '../../utils';
import style from './index.less';

class RiskUpdateHome extends React.Component<StateType> {
  public state = {
    showUpdateHome: true,
  };

  toResultPage = () => {
    this.setState({
      showUpdateHome: false,
    });
  };

  toUpdateHomePage = () => {
    this.setState({
      showUpdateHome: true,
    });
  };

  render() {
    return (
      <div className={style.riskUpdateStyle}>
        {this.state.showUpdateHome ? (
          <RiskUpdate toResultPage={this.toResultPage} />
        ) : (
          <UpdateResult toUpdateHomePage={this.toUpdateHomePage} />
        )}
      </div>
    );
  }
}

export default connect(mapStateToProps)(RiskUpdateHome);
